#pragma once

namespace struggle
{
	template<class iterator,class ref,class ptr>
	struct reverseiterator
	{
		typedef reverseiterator<iterator, ref, ptr> self;
		iterator _it;
		reverseiterator(iterator it)
			:_it(it)
		{}

		ref operator*()
		{
			iterator tmp = _it;
			return *(--tmp);
		}

		ptr operator->()
		{
			return &(operator*());
		}

		self& operator++()
		{
			--_it;
			return *this;
		}

		self& operator--()
		{
			++_it;
			return *this;
		}

		bool operator!=(const self& s) const
		{
			return _it != s._it;
		}
	};
}
